package sfy.md.suanfa.erfen;

import sfy.md.suanfa.paixu.maopao.MaoPao;

/**
 *  首先进行排序
 *  找到最中间的位置  x
 *  x与y进行比较    留下 一侧
 *  递归   直到找到相等的数字
 *
 * */
public class ErFenFind {

    public boolean  erFenFind(Integer[] shouldFindArray,int shouldFindNum){
        MaoPao maoPao = new MaoPao();
        Integer[] sorted =  maoPao.maoPao(shouldFindArray);
        int  z = sorted.length;
        double w = z/2;
        double r =  Math.ceil(w)-1;
        int k = (int) r;

       if(sorted[k]==shouldFindNum){
             return true;

       }
       if(sorted[k]>shouldFindNum){
             Integer[] param  = java.util.Arrays.copyOf(shouldFindArray,k);;
             erFenFind(param,shouldFindNum);
       }
        System.out.println("k:"+k);
       return false;
    }
}
